﻿using System;
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Syndication;
using System.ServiceModel.Web;

namespace ScottLane.MediaFeeder.WebService
{
    /// <summary>
    /// 
    /// </summary>
    [ServiceContract]
    [ServiceKnownType(typeof(Atom10FeedFormatter))]
    [ServiceKnownType(typeof(Rss20FeedFormatter))]
    public interface IMediaService
    {
        #region Music Operations

        [OperationContract]
        [WebGet(UriTemplate = "music/albums/{albumID}")]
        SyndicationFeedFormatter GetAlbum(string albumID);

        [OperationContract]
        [WebGet(UriTemplate = "music/albums/{albumID}/songs?startIndex={startIndex}&maxResults={maxResults}")]
        SyndicationFeedFormatter GetAlbumSongs(string albumID, string startIndex, string maxResults);

        [OperationContract]
        [WebGet(UriTemplate = "music/albums/{albumID}/image/*")]
        Stream GetAlbumImage(string albumID);

        [OperationContract]
        [WebGet(UriTemplate = "music/albums?title={title}&artist={artist}&startIndex={startIndex}&maxResults={maxResults}")]
        SyndicationFeedFormatter GetAlbums(string title, string artist, string startIndex, string maxResults);

        [OperationContract]
        [WebGet(UriTemplate = "music/albums/{albumID}/play")]
        void PlayAlbum(string albumID);

        [OperationContract]
        [WebGet(UriTemplate = "music/artists/{name}")]
        SyndicationFeedFormatter GetArtist(string name);

        [OperationContract]
        [WebGet(UriTemplate = "music/artists/{name}/albums")]
        SyndicationFeedFormatter GetArtistAlbums(string name);

        [OperationContract]
        [WebGet(UriTemplate = "music/artists/{name}/songs?startIndex={startIndex}&maxResults={maxResults}")]
        SyndicationFeedFormatter GetArtistSongs(string name, string startIndex, string maxResults);

        [OperationContract]
        [WebGet(UriTemplate = "music/artists?name={name}&startIndex={startIndex}&maxResults={maxResults}")]
        SyndicationFeedFormatter GetArtists(string name, string startIndex, string maxResults);

        [OperationContract]
        [WebGet(UriTemplate = "music/playlists/{name}")]
        SyndicationFeedFormatter GetPlaylist(string name);

        [OperationContract]
        [WebGet(UriTemplate = "music/playlists/{name}/songs?startIndex={startIndex}&maxResults={maxResults}")]
        SyndicationFeedFormatter GetPlaylistSongs(string name, string startIndex, string maxResults);

        [OperationContract]
        [WebGet(UriTemplate = "music/playlists?name={name}&type={type}")]
        SyndicationFeedFormatter GetPlaylists(string name, string type);

        [OperationContract]
        [WebGet(UriTemplate = "music/playlists/{name}/play")]
        void PlayPlaylist(string name);

        [OperationContract]
        [WebGet(UriTemplate = "music/artists/{name}/play")]
        void PlayArtist(string name);

        [OperationContract]
        [WebGet(UriTemplate = "music/songs/{songID}")]
        SyndicationFeedFormatter GetSong(string songID);

        [OperationContract]
        [WebGet(UriTemplate = "music/songs/{songID}/file/*")]
        Stream GetSongFile(string songID);

        [OperationContract]
        [WebGet(UriTemplate = "music/songs?title={title}&artist={artist}&albumTitle={albumTitle}&albumArtist={albumArtist}&genre={genre}&year={year}&startIndex={startIndex}&maxResults={maxResults}&orderBy={orderBy}")]
        SyndicationFeedFormatter GetSongs(string title, string artist, string albumTitle, string albumArtist, string genre, string year, string startIndex, string maxResults, string orderBy);

        [OperationContract]
        [WebGet(UriTemplate = "music/songs/{songID}/play")]
        void PlaySong(string songID);

        [OperationContract]
        [WebGet(UriTemplate = "music/nowplaying/shuffle")]
        void Shuffle();

        [OperationContract]
        [WebGet(UriTemplate = "music/nowplaying/repeat")]
        void Repeat();

        // todo - queue, add song to queue
        // shuffle/repeat
        // playback/queue/shuffle

        #endregion

        #region Video Operations

        //[OperationContract]
        //[WebGet(UriTemplate = "videos/{videoID}")]
        //SyndicationFeedFormatter GetVideo(string videoID);

        //[OperationContract]
        //[WebGet(UriTemplate = "videos/{videoID}/play")]
        //void PlayVideo(string videoID);

        //[OperationContract]
        //[WebGet(UriTemplate = "videos/{videoID}/file/*")]
        //Stream GetVideoFile(string videoID);

        //[OperationContract]
        //[WebGet(UriTemplate = "videos/folders/{folderID}")]
        //SyndicationFeedFormatter GetVideoFolder(string folderID);

        //[OperationContract]
        //[WebGet(UriTemplate = "videos/")]
        //SyndicationFeedFormatter GetVideoRootVideos();  // todo - combine with other folder methods

        //[OperationContract]
        //[WebGet(UriTemplate = "videos/folders")]
        //SyndicationFeedFormatter GetVideoRootFolders();  // todo - combine with other folder methods

        //[OperationContract]
        //[WebGet(UriTemplate = "videos/folders/{folderID}/folders")]
        //SyndicationFeedFormatter GetVideoFolderFolders(string videoID);

        //[OperationContract]
        //[WebGet(UriTemplate = "videos/folders/{folderID}/videos")]
        //SyndicationFeedFormatter GetVideoFolderVideos(string videoID);

        //Videos: /media/videos/folders      -> root folder

        //    /media/videos/folders/{folderid}     -> folder details

        //    /media/videos/folders/{folderid}/folders

        //    /media/videos/folders/{folderid}/videos

        //    /media/videos/{videoid}    -> video details

        //    /media/videos/{videoid}/play         -> plays the video in media center

        //    /media/videos/{videoid}/file

        #endregion

        #region Remote Control

        [OperationContract]
        [WebGet(UriTemplate = "remote/buttons")]
        SyndicationFeedFormatter GetButtons();

        [OperationContract]
        [WebGet(UriTemplate = "remote/buttons/pc")]
        SyndicationFeedFormatter PushPCButton();

        [OperationContract]
        [WebGet(UriTemplate = "remote/buttons/record")]
        SyndicationFeedFormatter PushRecordButton();

        [OperationContract]
        [WebGet(UriTemplate = "remote/buttons/stop")]
        SyndicationFeedFormatter PushStopButton();

        [OperationContract]
        [WebGet(UriTemplate = "remote/buttons/pause")]
        SyndicationFeedFormatter PushPauseButton();

        [OperationContract]
        [WebGet(UriTemplate = "remote/buttons/play")]
        SyndicationFeedFormatter PushPlayButton();

        #endregion
    }
}
